package com.cloud.model;

import com.cloud.base.BaseEntity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.hibernate.validator.constraints.NotBlank;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/**
 *设备
 */
@Table(name = "tb_equipment")
@Entity
@EntityListeners(AuditingEntityListener.class)
public class Equipment extends BaseEntity {
    /**
     * 设备号
     */
    @NotBlank(message = "设备编号不能为空")
    private String number;
    /**
     * 总存储空间
     */
    private Integer totalRam;
    /**
     * 剩余空间
     */
    private Integer leftRam;
    /**
     * 别名
     */
    private String alias;
    /**
     * 类型
     */
    private String type;
    /**
     * ip地址
     */
    @NotBlank(message = "IP不能为空")
    private String ip;
    /**
     * 状态
     */
    private Integer status;
    @ManyToOne
    @JoinColumn(name = "class_id")
    @JsonIgnore
    private Class aClass;
    @OneToMany(mappedBy = "equipment",fetch = FetchType.LAZY,cascade = {CascadeType.MERGE,CascadeType.PERSIST})
    private Set<Affiche> affiches=new HashSet<>();
    @OneToMany(mappedBy = "equipment",fetch = FetchType.LAZY,cascade = {CascadeType.MERGE,CascadeType.PERSIST})
    private Set<HomeWork>homeWorkSet=new HashSet<>();
    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public Integer getTotalRam() {
        return totalRam;
    }

    public void setTotalRam(Integer totalRam) {
        this.totalRam = totalRam;
    }

    public Integer getLeftRam() {
        return leftRam;
    }

    public void setLeftRam(Integer leftRam) {
        this.leftRam = leftRam;
    }

    public String getAlias() {
        return alias;
    }

    public void setAlias(String alias) {
        this.alias = alias;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public Class getaClass() {
        return aClass;
    }

    public void setaClass(Class aClass) {
        this.aClass = aClass;
    }

    public Set<Affiche> getAffiches() {
        return affiches;
    }

    public void setAffiches(Set<Affiche> affiches) {
        this.affiches = affiches;
    }

    public Set<HomeWork> getHomeWorkSet() {
        return homeWorkSet;
    }

    public void setHomeWorkSet(Set<HomeWork> homeWorkSet) {
        this.homeWorkSet = homeWorkSet;
    }
}
